# -*- coding:utf8 *-
__author__ = 'Forcs'

from django.db import models

from wancake.models.base.models import BaseModel

import wancake.config as wc_config

class ActionInfo(BaseModel):
    """
    行为名称
    """
    code = models.IntegerField(null=False, default=-1)
    name = models.CharField(max_length=64, null=False, default='unknown')
    is_count = models.BooleanField(null=False, default=True)


class BaseActionRecord(BaseModel):
    """
    记录用户行为数据
    """
    stb_user_id = models.BigIntegerField(null=False)  # 机顶盒用户数据库中的id
    flavor = models.CharField(max_length=64, null=True)  # 渠道
    platform = models.PositiveSmallIntegerField(null=False, default=1)  # 平台
    action_code = models.IntegerField(null=False, default=-1)  # 行为码
    action_time = models.DateTimeField(null=True)  # 行为触发时间
    appkey = models.CharField(max_length=64, null=True)  # 应用标识
    session = models.CharField(max_length=32, null=True)  # 行为会话

    class Meta:
        abstract = True
        app_label = wc_config.DATABASE


class ActionContentRecord(BaseActionRecord):
    """
    记录内容行为数据
    """
    content_code = models.IntegerField(null=True)   # 内容编码
    content_name = models.CharField(max_length=64, null=True)  # 内容标题
    category_code = models.IntegerField(null=True)  # 栏目编码
    category_name = models.CharField(max_length=64, null=True)  # 栏目标题


class ActionPageRecord(BaseActionRecord):
    """
    记录页面行为数据
    """
    page_code = models.IntegerField(null=True, default=0)  # 页面编码
    page_name = models.CharField(max_length=32, null=True, default='unknown')  # 页面名称


class ActionEventsRecord(BaseActionRecord):
    """
    记录事件行为数据
    """
    event_name = models.CharField(max_length=64, null=True, default='unknown')  # 事件名称
    event_data = models.TextField(null=True)  # 事件数据

